package matchPattern

object ExceptionApp extends App {
  // IO
  var file = "text.txt"
  try{
    var a = 0
    lazy val i = 10 / a
    println(i)
  }catch {
    case e:ArithmeticException => println("divisor can be zero: " + e)
    case e:Exception => println(e.getMessage)
  }finally {

  }

  class Person

  case class CTO(name:String, floor:String) extends Person
  case class Employee(name:String, floor:String) extends Person
  case class Other(name:String, floor:String) extends Person

  def caseClassMatch(person: Person): Unit ={
    person match {
      case CTO(name, floor) => println("CTO name:" + name + " floor " + floor)
      case Employee(name, floor) => println("Employee name:" + name + " floor " + floor)
      case Other(name, floor) => println("Other name:" + name + " floor " + floor)
    }
  }

  caseClassMatch(CTO("aqie", "1f"))
}
